import request from '@/utils/request'
// import qs from 'qs'

// 在线用户

// 获取在线用户列表
export function getUserArray (params) {
  var data = fromData(params)
  return request({
    url: '/online/getUserArray',
    method: 'post',
    data
  })
}

// 删除用户
export function delUser (params) {
  var data = fromData(params)
  return request({
    url: '/online/del_user',
    method: 'post',
    data
  })
}

// 清除在线用户
export function clearUser (params) {
  var data = fromData(params)
  return request({
    url: '/online/clean',
    method: 'post',
    data
  })
}

// 获取在线用户信息
export function getUserInfo (params) {
  var data = fromData(params)
  return request({
    url: '/online/getUserInfo',
    method: 'post',
    data
  })
}

// 删除用户IP
export function delUserIp (params) {
  var data = fromData(params)
  return request({
    url: '/online/del_userIp',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
